package com.zigong.app.ui.dialog;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Message;
import android.view.View;

import com.ruihang.generalibrary.ui.dialog.BaseDialogFragment;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.zigong.app.R;

public class ConfirmDiaFragment extends BaseDialogFragment implements View.OnClickListener {
    private CustomFontTextView cancel_cv, sure_cv, content_cv;
    public static final int READ_OK = 1;
    public static final int CLEAN_OK = 2;
    private String content;
    private int type;

    public ConfirmDiaFragment() {

    }

    @SuppressLint("ValidFragment")
    public ConfirmDiaFragment(String content, int type) {
        this.content = content;
        this.type = type;
    }

    @Override
    protected int getContentRes() {
        return R.layout.dia_show_fragment;
    }

    @Override
    protected void initViews(Dialog dialog, Bundle savedInstanceState) {
        cancel_cv = (CustomFontTextView) dialog.findViewById(R.id.dia_show_cancel);
        sure_cv = (CustomFontTextView) dialog.findViewById(R.id.dia_show_sure);
        sure_cv.setTextColor(Color.RED);
        content_cv = (CustomFontTextView) dialog.findViewById(R.id.content_show);
        content_cv.setText(content);
        cancel_cv.setOnClickListener(this);
        sure_cv.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        if (v == cancel_cv) {
            dismissAllowingStateLoss();
        } else if (v == sure_cv) {
            if (callBack != null) {
                Message message = new Message();
                if(type==1) {
                    message.what = READ_OK;
                }else if(type ==2){
                    message.what = CLEAN_OK;
                }
                callBack.onCallBackMsg(this, message);
                dismissAllowingStateLoss();
            }
        }
    }


}
